import java.awt.*;
import java.math.BigDecimal;
import java.util.Scanner;


public class Calculator {
    private static String sign;
    public static void main(String[] args) {
        boolean l = true;
        double result=0;
        while (l) {
            System.out.println("欢迎使用该计算器！");
            Scanner scanner = new Scanner(System.in);
            System.out.println("请选择您需要的功能：");
            System.out.println("1.加法  2.减法  3.乘法  4.除法  5.阶乘  6.正弦  7.余弦  8.指数");
            int a = scanner.nextInt();
            switch (a) {
                case 1:
                    sign = "+";
                    System.out.println("请输入第一个数字：");
                    double numberOne = scanner.nextInt();
                    System.out.println("请输入第二个数字：");
                    double numberTwo = scanner.nextInt();
                    result = numberOne + numberTwo;
                    break;
                case 2:
                    sign = "-";
                    System.out.println("请输入第一个数字：");
                    double numberOne1 = scanner.nextInt();
                    System.out.println("请输入第二个数字：");
                    double numberTwo1 = scanner.nextInt();
                    result = numberOne1 - numberTwo1;
                    break;
                case 3:
                    sign = "*";
                    System.out.println("请输入第一个数字：");
                    double numberOne2 = scanner.nextInt();
                    System.out.println("请输入第二个数字：");
                    double numberTwo2 = scanner.nextInt();
                    result = numberOne2 * numberTwo2;
                    break;
                case 4:
                    sign = "/";
                    System.out.println("请输入第一个数字：");
                    double numberOne3 = scanner.nextInt();
                    System.out.println("请输入第二个数字：");
                    double numberTwo3 = scanner.nextInt();
                    result = numberOne3 / numberTwo3;
                    break;
                case 5:
                    System.out.println("请输入一个数字：");
                    double numberOne4 = scanner.nextInt();
                    if (numberOne4 < 0 || numberOne4 != (int) numberOne4) {
                        System.out.println("只能计算非负整数的阶乘！");
                    }
                    result = 1;
                    for (int i = 1; i <= numberOne4; i++) {
                        result *= i;
                    }
                    break;
                case 6:

                    System.out.println("请输入第一个数字：");
                    double numberOne5 = scanner.nextInt();
                    sign = "sin";
                    result = Math.sin(Math.PI*numberOne5/180);
                    break;
                case 7:
                    sign = "cos";
                    System.out.println("请输入一个数字：");
                    double numberOne6 = scanner.nextInt();
                    result = Math.cos(Math.PI*numberOne6/180);
                    break;
                case 8:

                    System.out.println("1.指数运算  2.对数运算");
                    int b = scanner.nextInt();
                    switch (b) {
                        case 1:
                        sign = "^";
                            System.out.println("请输入第一个数字：");
                            double numberOne7 = scanner.nextInt();
                            System.out.println("请输入第二个数字：");
                            double numberTwo7 = scanner.nextInt();
                        result = Math.pow(numberOne7, numberTwo7);
                        break;
                        case 2:
                            System.out.println("请输入第一个数字：");
                            double numberOne8 = scanner.nextInt();
                            System.out.println("请输入第二个数字：");
                            double numberTwo8 = scanner.nextInt();
                            result = Math.log(numberOne8)/Math.log(numberTwo8);
                            break;
                        default:
                            System.out.println("你的输入不符合，请重新输入！");
                            break;
                    }
            }
            System.out.println("计算结果为："+result);
            System.out.println("计算已完成！\n是否继续计算？\n1、继续。\n 输入其他退出");
            String y = scanner.next();
            if (y.equals("1")){

            }else {
                l = false;
                System.out.println("谢谢使用！");
            }
        }

    }
}